#include "IndexBuffer.h"

IndexBuffer::IndexBuffer(ID3D11Device * device, ID3D11DeviceContext* context) : Buffer(device, context)
{
}

IndexBuffer::~IndexBuffer()
{
}

bool IndexBuffer::init(const void * const data, const int nr_of_indices, const int size)
{
	D3D11_BUFFER_DESC bd;

	bd.Usage =			D3D11_USAGE_IMMUTABLE;
	bd.ByteWidth =		size * nr_of_indices;
	bd.BindFlags =		D3D11_BIND_INDEX_BUFFER;
	bd.CPUAccessFlags = 0;
	bd.MiscFlags =		0;
	D3D11_SUBRESOURCE_DATA d;
	d.pSysMem = data;
	HRESULT hr = device->CreateBuffer(&bd, &d, &buffer);

	if(SUCCEEDED(hr))
		return true;
	return false;
}

ID3D11Buffer * IndexBuffer::getBuffer()
{
	return buffer;
}